<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page import="com.park.layout.Blocks" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%-- JSTL表达式（判断，循环，输出） --%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <%-- 方法表达式（字符串截取，替换） --%>
<%@ taglib uri="http://www.wanwei.com/tags/tag" prefix="layout" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<layout:override name="<%=Blocks.BLOCK_HEADER_CSS%>">
    <link href="Content/style/common/style.min.css?v=${static_resource_version}" rel="stylesheet" type="text/css">
</layout:override>

<layout:override name="<%=Blocks.BLOCK_HEADER_SCRIPTS%>">
    <script src="Content/lib/jquery/jquery.validate/jquery.validate.js?v=${static_resource_version}"></script>
    <script src="Content/lib/jquery/jquery.validate.unobtrusive/jquery.validate.unobtrusive.js?v=${static_resource_version}"></script>
    <script src="Content/app/order/order_list.js?v=${static_resource_version}"></script>
    <script>
        $(document).ready(function () {
            // 配置表单校验
            $('#plus_count_form, #minus_count_form').validate({
                ignore: ":hidden"
            });
        });

        function logistics(obj, orderId){
            $.post("<%=basePath%>order/newLogistics", {orderId: orderId, orderStatus: $(obj).val()}, function (res) {
                alert(res.message);
                if(res.code == 1){
                    window.location.reload();
                }
            });
        }
    </script>
</layout:override>

<layout:override name="<%=Blocks.BLOCK_BODY%>">
    <div class="container-fluid" style="text-align: left">
        <div class="panel panel-default">
            <div class="panel-heading">订单查询</div>
            <div class="panel-body">
                <form class="form-inline" id="goods_filter_form" onsubmit="return false;">
                    <div class="form-group">
                        <select class="form-control" name="payStatus" style="width: 160px; height: auto;">
                            <option value="">全部支付状态</option>
                            <option value="1" <c:if test="${payStatus == 1}">selected</c:if> >已支付</option>
                            <option value="2" <c:if test="${payStatus == 2}">selected</c:if> >未支付</option>
                        </select>
                        <select class="form-control" name="orderStatus" style="width: 160px; height: auto;">
                            <option value="">全部订单状态</option>
                            <option value="1" <c:if test="${orderStatus == 1}">selected</c:if> >已发货</option>
                            <option value="2" <c:if test="${orderStatus == 2}">selected</c:if> >未发货</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>&nbsp;</label>
                        <a href="javascript:;" class="btn btn-success goods-filter">
                            <span class="glyphicon glyphicon-search"></span> 检索
                        </a>
                    </div>
                </form>
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table goods-list">
                        <thead>
                        <tr class="bg-info">
                            <th>订单号</th>
                            <th>用户头像</th>
                            <th>用户昵称</th>
                            <th>手机号码</th>
                            <th>订单总价</th>
                            <th>购买数量</th>
                            <th>支付状态</th>
                            <th>订单状态</th>
                            <th>收货人姓名</th>
                            <th>收货人电话</th>
                            <th>收货人地址</th>
                            <th>订单时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="o" items="${list}">
                            <tr>
                                <td>${o.orderNo}</td>
                                <td align="center" style="width: 80px; height: 80px;">
                                    <img src="${o.headImg}" style="width: 100%; height: 100%; border-radius: 50%;">
                                </td>
                                <td>${o.operatorName}</td>
                                <td>${o.operatorMobile}</td>
                                <td>${o.orderSumPrice}</td>
                                <td>${o.itemCount}</td>

                                <c:if test="${o.payStatus == 1}">
                                    <td class="text-success">已支付</td>
                                </c:if>
                                <c:if test="${o.payStatus == 2}">
                                    <td class="text-danger">未支付</td>
                                </c:if>

                                <c:if test="${o.orderStatus == 1}">
                                    <td class="text-success">已发货</td>
                                </c:if>
                                <c:if test="${o.orderStatus == 2}">
                                    <td class="text-danger">未发货</td>
                                </c:if>

                                <td>${o.name}</td>
                                <td>${o.mobile}</td>
                                <td>${o.areaName}</td>
                                <td>${o.createTime}</td>
                                <td>
                                    <select class="form-control" name="orderStatus" onchange="logistics(this, '${o.orderId}')" style="height: auto;">
                                        <option value="1" <c:if test="${o.orderStatus==1}">selected</c:if> >已发货</option>
                                        <option value="2" <c:if test="${o.orderStatus==2}">selected</c:if>>未发货</option>
                                    </select>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                    <nav class="pull-right" <c:if test="${count <= pageSize}">style="display: none;"</c:if> >
                        <p class="pull-left" style="margin: 12px 14px;">
                            <span>${pageSize}条/页</span>
                            <span>总${count}条</span>
                        </p>
                        <ul class="pagination pull-right">
                            <c:if test="${currentPage == 1}">
                                <li class="disabled">
                                    <a href="javascript:;" data-index="1">
                                        <span>首页</span>
                                    </a>
                                </li>
                                <li class="disabled">
                                    <a href="javascript:;" data-index="1">
                                        <span>上一页</span>
                                    </a>
                                </li>
                            </c:if>
                            <c:if test="${currentPage != 1}">
                                <li>
                                    <a class="page-first" href="javascript:;" data-index="1">
                                        <span>首页</span>
                                    </a>
                                </li>
                                <li>
                                    <a class="page-prev" href="javascript:;" data-index="${currentPage - 1}">
                                        <span>上一页</span>
                                    </a>
                                </li>
                            </c:if>
                            <c:forEach var="i" begin="1" end="${lastPage}">
                                <c:if test="${i == currentPage}">
                                    <li class="active"><a href="javascript:;" data-index="${i}">${i}</a></li>
                                </c:if>
                                <c:if test="${i != currentPage}">
                                    <li><a class="page-index" href="javascript:;" data-index="${i}">${i}</a></li>
                                </c:if>
                            </c:forEach>
                            <c:if test="${currentPage == lastPage}">
                                <li class="disabled">
                                    <a href="javascript:;" data-index="1">
                                        <span>下一页</span>
                                    </a>
                                </li>
                                <li class="disabled">
                                    <a href="javascript:;" data-index="1">
                                        <span>末页</span>
                                    </a>
                                </li>
                            </c:if>
                            <c:if test="${currentPage != lastPage}">
                                <li>
                                    <a class="page-next" href="javascript:;" data-index="${currentPage + 1}">
                                        <span>下一页</span>
                                    </a>
                                </li>
                                <li>
                                    <a class="page-last" href="javascript:;" data-index="${lastPage}">
                                        <span>末页</span>
                                    </a>
                                </li>
                            </c:if>
                        </ul>
                    </nav>
                    <c:if test="${fn:length(list) == 0}">
                        <p class="text-muted no-list-count">没有检索到任何记录！</p>
                    </c:if>
                </div>
            </div>
        </div>
    </div>
</layout:override>

<c:import url="../Shared/Layout.jsp">
    <c:param name="title" value="订单查询"/>
</c:import>
